from mmengine.runner import Runner
from mmengine.config import Config

from mmengine import init_default_scope, MODELS
from mmseg.models import segmentors
import os

os.chdir('/root/code/open-mmlab/mmsegmentation')
init_default_scope('mmseg')
config_file = '/root/code/open-mmlab/mmsegmentation/configs/segformer/segformer_mit-b3_8xb1-160k_cityscapes-1024x1024.py'
cfg = Config.fromfile(config_file)
cfg.work_dir = 'work_dir'
print(cfg)
# runner = Runner.from_cfg(cfg)
# model = runner.model
model: segmentors.EncoderDecoder= MODELS.build(cfg['model'])
model.init_weights()
print(model)